require("coc_config")

--- Set some nvim settings ---
vim.o.encoding = "utf-8"
vim.o.fileencoding = "utf-8"
vim.o.fileformat = "unix"
vim.o.backup = false
vim.o.writebackup = false
vim.o.signcolumn = "yes"
vim.o.number = true
vim.o.relativenumber = true
vim.o.autoindent = true
vim.o.shiftwidth = 4
vim.o.smarttab = true
vim.o.expandtab = true
vim.o.mouse = "a"
vim.o.undofile = true
vim.o.undodir = vim.fn.expand("~") .. "/.vim/undo"
vim.o.scrolloff = 7
vim.o.colorcolumn = "79"
vim.g.mapleader = "<space>"

--- Mappings ---

-- Tab opening.
vim.keymap.set("n", "<C-J>", "gT")
vim.keymap.set("n", "<C-K>", "gt")
vim.keymap.set("n", "<C-t>", "<cmd>tabnew<CR>")

-- Telescope.nvim
vim.keymap.set("n", "<leader>ff", "<cmd>Telescope find_files<cr>")
vim.keymap.set("n", "<leader>fg", "<cmd>Telescope live_grep<cr>")
vim.keymap.set("n", "<leader>fb", "<cmd>Telescope buffers<cr>")
vim.keymap.set("n", "<leader>fh", "<cmd>Telescope help_tags<cr>")

-- Misc.
vim.keymap.set("n", "<F8>", "<cmd>TagbarToggle<CR>")
vim.keymap.set("n", "<C-h>", "<cmd>w<CR><cmd>!python %<CR>")
vim.keymap.set("n", ",<leader>", "<cmd>noh<CR>")
vim.keymap.set("n", "<silent>gdd", "<cmd>call CocAction('jumpDefinition')<CR>")
vim.keymap.set("n", "<F5>", "<cmd>UndotreeToggle<CR>")

--- Call plug-ins ---
local Plug = vim.fn['plug#']
vim.call("plug#begin")

Plug 'vim-airline/vim-airline'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug('neoclide/coc.nvim', {branch = 'release'})
Plug 'vim-scripts/indentpython.vim'
Plug 'airblade/vim-rooter'
Plug 'cocopon/iceberg.vim'
Plug 'nvim-lua/plenary.nvim'
Plug('nvim-telescope/telescope.nvim', {tag = '0.1.1'})
Plug 'mbbill/undotree'
Plug 'preservim/tagbar'

vim.call("plug#end")

--- Apperance settings ---
vim.cmd.colorscheme("iceberg")
vim.api.nvim_set_hl(0, "Normal", {ctermbg=none})
vim.api.nvim_set_hl(0, "NonText", {ctermbg=none})
vim.api.nvim_set_hl(0, "LineNr", {ctermbg=none})
